<!--编辑期中活动评价-->
<template>
  <div class="wrapper-container">
    <el-form ref="form" class="my-form">
      <el-row class="single-row">
        <el-col :span="24">
          <el-row class="item-row">
            <el-col class="name-col" :span="6"> 学期</el-col>
            <el-col class="content-col" :span="18">
              <SelectItem
                :name="''"
                :value="tableData.term"
                @change="
                  (e) => {
                    tableData.term = e;
                  }
                "
                :xqList="xqList"
              ></SelectItem>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row class="single-row">
        <el-col :span="24">
          <el-row class="item-row">
            <el-col class="name-col" :span="6"> 评价活动名称</el-col>
            <el-col class="content-col" :span="18">
              <el-input
                v-model="tableData.evalprojectname"
                style="width: 50%"
                size="small"
              ></el-input>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row class="single-row">
        <el-col :span="12">
          <el-row class="item-row">
            <el-col class="name-col" :span="12"> 开始时间</el-col>
            <el-col class="content-col" :span="12">
              <el-date-picker
                v-model="tableData.begindate"
                type="datetime"
                placeholder="选择开始时间"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width: 50%"
              >
              </el-date-picker>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="12">
          <el-row class="item-row">
            <el-col class="name-col" :span="12"> 结束时间</el-col>
            <el-col class="content-col" :span="12">
              <el-date-picker
                v-model="tableData.enddate"
                type="datetime"
                placeholder="选择结束时间"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width: 50%"
              >
              </el-date-picker>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row class="single-row">
        <el-col :span="24">
          <el-row class="item-row" style="height: 415px">
            <el-col class="name-col" style="height: 100%" :span="6">
              评价说明
            </el-col>
            <el-col class="content-col" style="height: 100%" :span="18">
              <el-input
                style="width: 96%; margin: 10px 0; height: 400px"
                type="textarea"
                placeholder="请输入内容"
                v-model="tableData.teaching"
              >
              </el-input>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </el-form>


    <div class="bottom-block">
      <div style="width: 300px; display: flex; justify-content: space-around">
        <ButtonItem
          :name="'保存'"
          :link="''"
          :icon="''"
          :buttonColor="'yellow'"
          @click="save"
        ></ButtonItem>

        <ButtonItem
          :name="'取消'"
          :link="''"
          :icon="''"
          :buttonColor="'red'"
          @click="Cancel"
        ></ButtonItem>
      </div>
    </div>
  </div>
</template>

<script>
import SelectItem from "../../../components/SelectItem.vue";
import ButtonItem from "../../../components/ButtonItem.vue";

import {
  ByAllRankAndGuide,
  insert,
} from "@/api/evaluation/setActivityEvaluations";
import {pjevalprojectById} from "../../../api/teacher/admin";

export default {
  components: {
    SelectItem,
    ButtonItem,
  },
  data() {
    return {

      tableData: {
        // guiderankoption: '',//各个等级比例
        teaching: '',//评教说明
        guidename: '',//指标项名称
        evalprojectname: '',//评价活动名称
        enddate: '',//结束时间
        begindate: '',//开始时间
        term: '2021春',//学期
        type: 2,
      },

      term: "2021春",
      xqList: [
        {
          value: "2021春",
          label: "2021春",
        },
        {
          value: "2020夏",
          label: "2020夏",
        },
      ],
      guidename: '',
      systemList: [
        {
          value: "2021春,2021春,2021春,2021春,2021春,2021春,2021春,2021春",
          label: "2021春",
        },
        {
          value: "a,b,c,d,e",
          label: "2020夏",
        },
      ],
      teacherList: [],
      classList: [],
      baseInfo: {
        courseName: "",
      },
      proportionalList: [],
      multipleSelection: [],
      propor: {
        level1: "",
        level2: "",
        level3: "",
        level4: "",
        level5: "",
        level6: "",
        level7: "",
        level8: "",
        level9: "",
        level10: "",
        level0: ""
      }
    };
  },
  watch: {
    guidename(val) {
      if (val) {
        this.proportionalList = this.systemList[val].guiderankoption.split(',')
      }

    },
  },
  mounted() {
    this.pjevalprojectById()
  },
  methods: {

    //查询
    pjevalprojectById(){
      let id = {}
      id = this.$route.query.evalprojectid
      return new Promise(() => {
        pjevalprojectById(id).then(res => {
          this.tableData = res.data.data
        })
      })
    },

    save() {
      let obj = this.tableData
      let arr = []
      if (!obj.term) {
        this.$message.error('学期未填写');
        return
      }
      if (!obj.evalprojectname) {
        this.$message.error('评价活动名称未填写');
        return
      }
      if (!obj.begindate) {
        this.$message.error('开始时间未填写');
        return
      }
      if (!obj.enddate) {
        this.$message.error('结束时间未填写');
        return
      }
      if (!obj.teaching) {
        this.$message.error('评教说明未填写');
        return
      }

      obj.type = 2
      obj.proportionallimit = arr.toString()
      return new Promise(() => {
        insert(obj).then(res => {
          console.log(res.status)
          if (res.status === 200) {
            let pathname = '/' + window.location.pathname.split('/')[1]
            this.$router.push(pathname + "/examination/setPrintEntryb");
          }
        })
      })
    },
    Cancel(){
      let pathname = '/' + window.location.pathname.split('/')[1]
      this.$router.push(pathname + "/examination/setPrintEntryb");
    },

    ByAllRankAndGuide() {
      return new Promise(() => {
        ByAllRankAndGuide().then(res => {
          if (res.data.code === 200) {
            let data = res.data.data
            let arr = []
            for (const dataKey in data) {
              let obj = {...data[dataKey].pjEvalguide, ...data[dataKey].pjGuiderank}
              obj = {
                value: dataKey,//obj.guiderankoption
                label: obj.guidename,
                guiderankoption: obj.guiderankoption,
              }
              arr.push(obj)

            }
            this.systemList = arr

          }
        })
      })
    }


  },
  computed: {},
};
</script>
<style lang="less" scoped>
.el-textarea__inner {
  border-color: #004ca7;
  font-size: 14px;
  color: #004ca7;
  font-family: "Microsoft YaHei";
  height: 90px;
}

.search-container {
  justify-content: flex-start !important;
}

.search-button {
  cursor: pointer;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 27px;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  border-radius: 6px;

  > span {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }

  > img {
    width: 19px;
    height: 19px;
    margin-right: 4px;
  }
}

.table-container {
  margin-top: 30px;

  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }

  .wrapper-button {
    display: flex;
    flex-direction: column;
    align-items: center;

    > div {
      margin-bottom: 8px;
    }
  }
}
</style>

<style lang="less" scoped>
.item-row .el-col {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 70px;
  border-right: none !important;
}

.item-row .el-col:not(:first-child) {
  border-left: 1px solid rgba(0, 76, 167, 0.39);
}

.single-row .el-col:not(:last-child) {
  border-right: 1px solid rgba(0, 76, 167, 0.39);
}

.my-form .single-row:not(:last-child) {
  border-bottom: 1px solid rgba(0, 76, 167, 0.39);
}

.name-col {
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: #004ca7;
  background: rgba(77, 129, 192, 0.1);
}

.content-col {
  padding-left: 40px;
  color: #004ca7;
}

.wrapper-container {
  .my-form {
    width: 100%;
    border: 1px solid rgba(0, 76, 167, 0.8);
    margin: 57px auto 19px;
    border-radius: 9px;
  }
}

@import "../../../styles/special.less";
.bottom-block {
  padding-top: 30px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.table-container ::v-deep .el-table--border .el-table__cell:first-child .cell {
  padding-left: 10px !important;
}

.filter-button1::v-deep .el-radio-button .el-radio-button__inner {
  border-radius: 6px !important;
  border: 1px solid rgb(245, 134, 106);
  color: rgb(245, 134, 106);
  background-color: rgb(254, 237, 226);
}

.filter-button1::v-deep
.el-radio-button__orig-radio:checked
+ .el-radio-button__inner {
  border: 1px solid rgb(245, 134, 106);
  color: white;
  background-color: rgb(245, 134, 106);
}

.filter-button {
  display: flex;
  margin-top: 27px;
}

.wrapper-container {
  width: 1711px;
  margin: 0 auto;
}

.table-container {
  margin-top: 30px;

  .table-data {
    margin-top: 10px;
    border: 0.8px solid #004ca7;
    border-radius: 9px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}

.save-button {
  width: 87px;
  height: 36px;
  line-height: 36px;
  background: #fff6ef;
  border: 1px solid #f3b815;
  border-radius: 6px;
  font-size: 18px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #f3b815;
  text-align: center;
  margin: 82px auto;
}

.zuoyou {
  width: 200px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
</style>
<style lang="less" scoped>
/deep/ .search-container-item .el-select {
  width: 170px !important;
}
</style>
